package com.ziyun.erp.web.modules.mian.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.utility.New;
import com.ziyun.erp.modules.main.service.MainService;
import com.ziyun.erp.modules.main.vo.WaitInfoVo;
import com.ziyun.erp.modules.promotion.entity.ConfigCouponUcenterEntity;
import com.ziyun.erp.modules.promotion.service.ConfigCouponUcenterService;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zh
 * @date 2018/12/1111:37
 */
@RestController
@RequestMapping("main")
public class MainController {
    @Autowired
    private MainService mainService;

    @Autowired
    private ConfigCouponUcenterService configCouponUcenterService;

    /**
     * 首页信息
     * @return
     */
    @RequestMapping("/mainInfo")
    public R list(){
        WaitInfoVo waitInfoVo =  mainService.selectWaitInfo();
        List<ConfigCouponUcenterEntity> configCouponUcenterList = this.configCouponUcenterService.selectList(new EntityWrapper<ConfigCouponUcenterEntity>()
                                .eq("coupon_give",1)
                                .orderBy("create_time", false)
         );

        return R.ok().put("waitInfoVo", waitInfoVo).put("configCouponUcenterList",configCouponUcenterList);
    }

    /**
     * 首页信息
     * @return
     */
    @Value("${oss.host}")
    String ossHost;
    @RequestMapping("/configInfo")
    public R configInfo(){
        Map<String,Object>  configInfo = New.hashMap();
        // 获取oss 配置
        configInfo.put("ossHost",ossHost);

        return R.ok().put("configInfo", configInfo);
    }

}
